import requests


def get_page():
    url = "http://piping.mogumiao.com/proxy/api/get_ip_bs?appKey=01b92090f7b045bb8d7b5530dad03dd7&count=1&expiryDate=0&format=1&newLine=2"
    headers = {
        "User-Agent": "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)"
    }
    response = requests.get(url, headers=headers)
    # print(response.status_code)
    if response.status_code == 200:
        return response.json()


def get_proxies():
    json_result = get_page()
    print(json_result)
    ip = json_result['msg'][0]['ip']
    port = json_result['msg'][0]['port']
    proxy = ip + ':' + port
    proxies = {
        'http': 'http://' + proxy,
        'https': 'https://' + proxy
    }
    return proxies
    # return proxy


if __name__ == '__main__':
    proxies = get_proxies()
    print(proxies)
